﻿Public Class MonDAO
    Public Shared Function LayDanhSach(ByVal maLoai As Integer) As List(Of CMon)
        Dim list As New List(Of CMon)
        Dim str As String = String.Format("SELECT * FROM Mon where MaLoai={0}", maLoai)

        Dim dt As DataTable = CKetNoi.ExecQuery(str)

        For Each i As DataRow In dt.Rows
            Dim mon As New CMon
            mon.MaMon = i("MaMon")
            mon.MaLoai = i("MaLoai")
            mon.TenMon = i("TenMon")
            mon.DonGia = i("DonGia")
            mon.ImagePath = i("ImagePath")
            list.Add(mon)
        Next
        Return list
    End Function
    Public Shared Function Insert(ByVal b As CMon) As Integer

        Dim sql As String = String.Format("INSERT INTO Mon(TenMon,MaLoai,DonGia,ImagePath) VALUES('{0}',{1},{2},'{3}')", b.TenMon, b.MaLoai, b.DonGia, b.ImagePath)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Delete(ByVal maBan As Integer) As Integer
        Dim sql As String = String.Format("Delete from Mon where MaMon={0}", maBan)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
End Class
